<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "stock_balance".
 *
 * @property int $id
 * @property int $tally_id 所属账本
 * @property int $product_id 产品ID
 * @property string $product_title 产品名称
 * @property string $product_spec 产品规格
 * @property string $product_unit 产品单位
 * @property string $product_cost_price 成本价
 * @property string $in_num 入库数量（总）
 * @property string $out_num 出库数量（总）
 * @property string $balance_money 库存余额（总）
 * @property string $created_time 创建时间
 * @property string $updated_time 更新时间
 * @property int $state 1正常0不显示
 */
class StockBalance extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'stock_balance';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['tally_id', 'product_id', 'state'], 'integer'],
            [['product_unit'], 'required'],
            [['product_cost_price', 'in_num', 'out_num', 'pure_num', 'balance_money'], 'number'],
            [['created_time', 'updated_time'], 'safe'],
            [['product_title', 'product_spec'], 'string', 'max' => 255],
            [['product_unit'], 'string', 'max' => 30],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'tally_id' => 'Tally ID',
            'product_id' => 'Product ID',
            'product_title' => 'Product Title',
            'product_spec' => 'Product Spec',
            'product_unit' => 'Product Unit',
            'product_cost_price' => 'Product Cost Price',
            'in_num' => 'In Num',
            'out_num' => 'Out Num',
            'pure_num' => 'Pure Num',
            'balance_money' => 'Balance Money',
            'created_time' => 'Created Time',
            'updated_time' => 'Updated Time',
            'state' => 'State',
        ];
    }
}
